import com.sun.jmx.snmp.internal.SnmpSubSystem;
import sun.util.resources.LocaleData;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.Date;

public class Test2 {
    public static void main(String[] args) throws ParseException {
        //请使用代码，计算你过了多少天，用JDK7和JDK8两种方式完成。

        //JDK7
        //只要对时间进行计算或者判断，都需要获取时间的毫秒值
        String birthday = "2000年10月1日";
        SimpleDateFormat sdf = new SimpleDateFormat("yyy年MM月dd日");
        Date date = sdf.parse(birthday);
        //获取出生时间的毫秒值
        long birthdayTime = date.getTime();
        //获取当前时间的毫秒值
        long currentTime = System.currentTimeMillis();
        long time = currentTime - birthdayTime;
        System.out.println(time / 1000 / 60 / 60 / 24);

        //JDK8
        LocalDate ld1 = LocalDate.of(2000,10,1);

        LocalDate ld2 = LocalDate.now();

        long days = ChronoUnit.DAYS.between(ld1,ld2);
        System.out.println(days);
    }
}
